package _220327;

import java.util.Scanner;

/**
 * @author ShadowLim
 * @create 2022-03-27-8:56
 */
public class 旋转 {
    static int N = 110;
    static int[][] a = new int[N][N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt(), n = scanner.nextInt();
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = scanner.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = m - 1; j >= 0; j--) {
                System.out.print(a[j][i] + " ");
            }
            System.out.println();
        }
    }
}
